package Or

import (
	"context"
	"db2s/ETL"
	"db2s/global"
	"db2s/parDef"
	"db2s/ref"
)

func (Go GolF) Position(ctx context.Context) (result global.Return, err error) {
	var event = "[Position]"
	defer func() { err = ref.RecoverPanic(event, recover()) }()
	var _, table = parDef.GetExecFuncParameterValueBase(ctx)
	select {
	case <-ctx.Done():
		err = ctx.Err()
		return
	default:
		switch scn := parDef.GetParameterValueAnyToString(parDef.GetFuncParameterValue(ctx, "position")); scn {
		case "auto":
			if result, err = parDef.SqlExec(parDef.GetSubSqlExecFuncParameterValue(ctx, event, ETL.String, positionSysObjectView, getFullTableScnSql, QueryColValManage)); err != nil {
				return
			}
			return parDef.ResultExec(parDef.NewGetExternalExecFuncParameterValue(ctx, event, result, result.Result, table))
		default:
			result.Result = scn
			return
		}
	}
}
